package com.dkd.day20250616;

public class Solutionjudge {
    public static void main(String[] args) {

        String s4 = "absba";

        System.out.println(judge(s4));
    }
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param str string字符串 待判断的字符串
     * @return bool布尔型
     */
    public static boolean judge (String str) {
        // write code here
        //判断是否为回文字符串
        if(str == null || str.length() == 0 ||str.length() == 1) return true;
        int left = 0, right = str.length()-1;
        while (left < right) {
            if (str.charAt(left) == str.charAt(right)) {
                left++;
                right--;
            }else{
                return false;
            }
        }
        return true;
    }
}
